<g:set var="pageNumber" value="${Math.ceil(offset / itemsPerPage) + 1}" />

<ul class="pagination">
    <g:if test="${pageNumber == 1}">
    <li class="disabled"><a href="#">&laquo;</a></li>        
    </g:if>
    <g:else>
    <li><a href="#" onclick="return ${changeOffsetFunction}(${itemsPerPage * (pageNumber-2)})">&laquo;</a></li>
    </g:else>
    <g:each in="${1..Math.ceil(totalItems / itemsPerPage)}" var="i">
    <li class="${pageNumber == i ? 'active' : ''}"><a href="#" onclick="${changeOffsetFunction}(${(i - 1) * itemsPerPage})">${i}</a></li>
    </g:each>
    <g:if test="${pageNumber < totalItems / itemsPerPage}">
    <li><a href="#" onclick="return ${changeOffsetFunction}(${itemsPerPage * pageNumber})">&raquo;</a></li>
    </g:if>
    <g:else>
    <li class="disabled"><a href="#">&raquo;</a></li>
    </g:else>
</ul>

